package com.newmainsoftech.dao.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
public class AbstractEntityIdentifierImplTestEntity 
extends AbstractEntityIdentifierImpl implements Serializable {
	@Transient
	private static final long serialVersionUID = 1L;

	@Basic( optional = true)
	private String name;
		public String getName() {
			return name;
		}
		public void setName( final String name) {
			this.name = name;
		}

	@Basic( optional = false)
	@Temporal( value = TemporalType.TIMESTAMP)
	private Date creationDate;
		public Date getCreationDate() {
			return creationDate;
		}
		protected void setCreationDate( final Date creationDate) {
			this.creationDate = creationDate;
		}

	@Basic( optional = false)
	@Temporal( value = TemporalType.TIMESTAMP)
	private Date lastUpdate;
		public Date getLastUpdate() {
			return lastUpdate;
		}
		public void setLastUpdate( final Date lastUpdate) {
			this.lastUpdate = lastUpdate;
		}
		
	@PrePersist
	protected void prePersist() {
		Date date = new Date();
		setCreationDate( date);
		setLastUpdate( date);
	}
	@PreUpdate
	protected void preUpdate() {
		Date date = new Date();
		setLastUpdate( date);
	}
	
	private long longData = (new Date()).getTime();
		public long getLongData() {
			return longData;
		}
		public void setLongData( long longData) {
			this.longData = longData;
		}
		
	@Override
	public String toString() {
		String thisStr = super.toString();
		return thisStr.substring( 0, thisStr.lastIndexOf( "]"))
				.concat( name == null ? "" : ", name=" + name)
				.concat( creationDate == null ? "" : ", creationDate = " + creationDate)
				.concat( lastUpdate == null ? "" : ", lastUpdate = " + lastUpdate)
				.concat( ", longData=" + longData)
				.concat( "]");
	}
}
